#include<string.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
int main( int argc , char ** argv ){

	#define MAX_LEN 20

	int fd = fileno(stdin);

	char buf[ MAX_LEN ];

	memset( buf , 0  , MAX_LEN );
	
	int flags = fcntl( fd , F_GETFD );
	if( flags< 0 ){
		perror( "fnctl F_GETFD ERROR\n" );
		return -1;
	}

	if (fcntl( fd , F_SETFL, flags & (~O_NONBLOCK)) < 0){ 
		printf( "fnctl F_SETFL ERROR\n" );
		return -1;
	}

	while(1){
		int len = read( fd , buf , MAX_LEN );
		printf( "%s\n" , buf );
		sleep(1);
	}
	return 0;
}
